﻿<UserControl x:Class="Northwind.UI.WPF.OrderDetailsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="400" d:DesignWidth="300">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Skins/MainSkin.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Border Padding="5"
                Margin="4" Grid.Row="0"
                CornerRadius="5"
                Background="{StaticResource mainBlueBrush}">
            <TextBlock Text="{Binding Name}"
                       Foreground="White"
                       FontWeight="Bold"
                       FontSize="12" />
        </Border>
         <GroupBox Header="Customer Details"                  
                  IsEnabled="False"
                  Grid.Row="1"
                  >
            <Grid Margin="4">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="6" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Label Content="Company Name:" Grid.Row="0" Grid.Column="0"
                       HorizontalAlignment="Right" />
                <TextBox Text="{Binding Path=Order.Customer.CompanyName, 
                         UpdateSourceTrigger=PropertyChanged}" Grid.Row="0"
                         Grid.Column="2" />
                <Label Content="Contact Name:"
                       Grid.Row="1"
                       HorizontalAlignment="Right" />
                <TextBox Text="{Binding Order.Customer.ContactName, 
                         UpdateSourceTrigger=PropertyChanged}"
                         Grid.Row="1"
                         Grid.Column="2" />
                <Label Content="Phone Number:"
                       Grid.Row="2"
                       HorizontalAlignment="Right" />
                <TextBox Text="{Binding Order.Customer.Phone, 
                         UpdateSourceTrigger=PropertyChanged}"
                         Grid.Row="2"
                         Grid.Column="2" />
                <Label Content="Address:"
                       Grid.Row="3"
                       HorizontalAlignment="Right" />
                <TextBox Text="{Binding Order.Customer.Address, 
                         UpdateSourceTrigger=PropertyChanged}"
                         Grid.Row="3"
                         Grid.Column="2" />
                </Grid>
        </GroupBox>
        <GroupBox Header="Employee Details"      
                  IsEnabled="False"
                  Grid.Row="2"
                  DockPanel.Dock="Bottom">
            <Grid Margin="4">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="6" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Label Content="First Name:" Grid.Row="0" Grid.Column="0"
                       HorizontalAlignment="Right" />
                <TextBox Text="{Binding Path=Order.Employee.FirstName, 
                         UpdateSourceTrigger=PropertyChanged}" Grid.Row="0"
                         Grid.Column="2" />
                <Label Content="Last Name:"
                       Grid.Row="1"
                       HorizontalAlignment="Right" />
                <TextBox Text="{Binding Order.Employee.LastName, 
                         UpdateSourceTrigger=PropertyChanged}"
                         Grid.Row="1"
                         Grid.Column="2" />
            </Grid>
        </GroupBox>
        <GroupBox Header="Order Details"      
                  Grid.Row="3"
                  >
            <Grid Margin="4">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="6" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Label Content="Order Date:" Grid.Row="0" Grid.Column="0" IsEnabled="False"
                       HorizontalAlignment="Right" />
                <TextBox Text="{Binding Path=Order.OrderDate, Mode=OneWay,
                         UpdateSourceTrigger=PropertyChanged}" Grid.Row="0" IsEnabled="False"
                         Grid.Column="2" />
                <Label Content="Shipped Date:" Grid.Row="1" Grid.Column="0" IsEnabled="False"
                       HorizontalAlignment="Right" />
                <TextBox Text="{Binding Path=Order.ShippedDate, Mode=OneWay,
                         UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" IsEnabled="False"
                         Grid.Column="2" />
                <Label Content="Freight:" Grid.Row="2" Grid.Column="0" IsEnabled="False"
                       HorizontalAlignment="Right" />
                <TextBox Text="{Binding Path=Order.Freight, Mode=OneWay,
                         UpdateSourceTrigger=PropertyChanged}" Grid.Row="2" IsEnabled="False"
                         Grid.Column="2" />
                <Label Content="Order Total $:" Grid.Row="3" Grid.Column="0" IsEnabled="False"
                       HorizontalAlignment="Right" />
                <TextBox Text="{Binding Path=Order.Total, Mode=OneWay,
                         UpdateSourceTrigger=PropertyChanged}" Grid.Row="3" IsEnabled="False"
                         Grid.Column="2" />
                <!--<Label Content="Order Total:" Grid.Row="3" Grid.Column="0" IsEnabled="False"
                       HorizontalAlignment="Right" />
                <TextBox Text="{Binding Path=Order.Total, Mode=OneWay,
                         UpdateSourceTrigger=PropertyChanged}" Grid.Row="3" IsEnabled="False"
                         Grid.Column="2" />-->
                <ListView ItemsSource="{Binding Order.OrderDetails}" Grid.Row="4" Grid.ColumnSpan="3" >
                    <ListView.Resources>
                        <Style TargetType="ListViewItem">
                            <Setter Property="HorizontalContentAlignment"
                                Value="Stretch" />
                        </Style>
                    </ListView.Resources>
                    <ListView.View>
                        <GridView>
                            <GridView.Columns>
                                <GridViewColumn Header="Product">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock TextAlignment="Left"
                                                   Text="{Binding Product.ProductName}"  />
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <GridViewColumn Header="Quantity">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock TextAlignment="Center"
                                                   Text="{Binding Quantity}"  />
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <GridViewColumn Header="UnitPrice">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock TextAlignment="Center" 
                                                   Text="{Binding UnitPrice, StringFormat='{}{0:C}'}" />
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                            </GridView.Columns>
                        </GridView>
                    </ListView.View>
                </ListView>
            </Grid>
        </GroupBox>
    </Grid>
</UserControl>
